from wish.pool.role_pool import RolePool
from wish.pool.sr_weapon_pool import SrWeaponPool


def get_case(times):
    silver = False
    yukong = False
    luocha = False
    weapon = False
    role_pool = RolePool()
    weapon_pool = SrWeaponPool()

    i = 0
    while i < times:
        if silver and yukong and luocha and weapon:
            break
        i += 1

        if not silver and i < 40:
            role_res = role_pool.next()
            if role_res == RolePool.ROLE_5_UP:
                silver = True
            continue

        if not yukong or not luocha:
            role_res = role_pool.next()
            if role_res == RolePool.ROLE_5_UP:
                luocha = True
            if role_res == RolePool.ROLE_4_UP_A:
                yukong = True
        else:
            weapon_res = weapon_pool.next()
            if weapon_res == SrWeaponPool.WEAPON_5_UP:
                weapon = True

    return parse_case(silver, yukong, luocha, weapon)


def parse_case(silver, yukong, luocha, weapon):
    if not silver and not yukong and not luocha:
        return 17, '啥也无'
    elif not silver and yukong and luocha and weapon:
        return 13, '罗刹+驭空+武器'
    elif not silver and yukong and luocha and not weapon:
        return 14, '罗刹+驭空'
    elif not silver and yukong and not luocha and not weapon:
        return 16, '驭空'
    elif not silver and not yukong and luocha and not weapon:
        return 15, '罗刹'
    elif silver and yukong and luocha and weapon:
        return 8, '全部拿下'
    elif silver and yukong and luocha and not weapon:
        return 9, '银狼+罗刹+驭空'
    elif silver and yukong and not luocha and not weapon:
        return 11, '银狼+驭空'
    elif silver and not yukong and luocha and not weapon:
        return 10, '银狼+罗刹'
    elif silver and not yukong and not luocha and not weapon:
        return 12, '银狼'
    else:
        return '异常'
